<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">

    <link href="//www.bootcss.com/p/layoutit/css/bootstrap-combined.min.css" rel="stylesheet">
</head>
<html>
<body>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <h3 class="text-center">
                JSON数据链展示
            </h3>
        </div>
    </div>
    <div class="row-fluid">
        <div class="span2">
            <form class="form-search">
                <p>
                    输入目标地址
                </p>
                <p>
                    <input class="input-medium search-query" type="text"/>
                </p>
                <p>
                    <button class="btn" type="submit">查找</button>
                </p>
            </form>
            <ul class="nav nav-list">
                <li class="nav-header">
                    列表标题
                </li>
                <li>
                    <a href="/html">主网络</a>
                </li>
                <li class="active">
                    <a href="/html/datalink.html">数据链Demo</a>
                </li>
                <li>
                    <a href="/html/register.html">注册</a>
                </li>
                <li class="nav-header">
                    功能列表
                </li>
                <li>
                    <a href="/html/newdata.html">测试数据上传通道</a>
                </li>
                <li>
                    <a href="#">设置</a>
                </li>
                <li class="divider">
                </li>
                <li>
                    <a href="#">帮助</a>
                </li>
            </ul>
        </div>
        <div class="span10">
            <table class="table">
                <thead>
                <tr>
                    <th>
                        区块号
                    </th>
                    <th>
                        区块Hash
                    </th>
                    <th>
                        JSON数据
                    </th>
                    <th>
                        状态
                    </th>
                    <th>
                        详细
                    </th>
                </tr>
                </thead>
                <tbody>
                <tr v-for="i in mainnet" class="success">
                    <td>
                        {{i.height}}
                    </td>
                    <td>
                        {{i.block_hash}}
                    </td>
                    <td>
                        {{i.memo}}
                    </td>
                    <td>
                        已发块
                    </td>
                    <td>
                        <button class="btn" type="button" @click="dt(i.height)">展开区块</button>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>

</body>
</html>
<script src="//cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/vue/2.6.10/vue.js"></script>
<script>
    var vm = new Vue({
        el: '.container-fluid',
        data: {
            seen: true,
            mainnet: []
        },
        created: function () {
            this.blocks()
        },
        methods: {
            blocks() {
                $.ajax({
                    //请求方式
                    type: "post",
                    //请求地址
                    url: "/v1/cosmos/address/to",
                    //数据，json字符串
                    data: {
                        "address": "cosmos13v60v23sheck50em6jlvdqmmgkmp2n0qqrchsv"
                    },
                    success: function (ret) {
                        console.log(vm.mainnet);
                        vm.mainnet = ret;
                        console.log(vm.mainnet);
                    }
                });
            },
            dt(addr) {
                // alert(ddd)
                location.href = "detail.html?height=" + addr;
            }
        }
    })
</script>
</body>
</html>
